home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1996 April
/
Software of the Month Club 1996 April.iso
/
pc
/
os2
/
psutils
/
src
/
maketext
< prev
next >
Wrap
Text File
|
1996-02-21
|
1KB
|
38 lines
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
# maketext: perl filter to substitute names in scripts and man pages.
%change = (); # names -> substitutions
# get release and patchlevel for all scripts
open(H, "patchlev.h") || die "can't open patchlev.h";
while(<H>) {
$change{$1} = $2 if /^\#define\s*(\S*)\s*(\S*)/;
}
close(H);
foreach (@ARGV) {
if (/MAN=(.*)/) { # name.ext name.ext -> name(ext), name(ext)
local(@man) = split(' ', $1);
$change{"MAN"} = join(", ", grep(s/\.(.)/($1)/, @man));
} elsif (/PERL=(\/.*)/) { # substitute name for value
$change{"PERL"} = "\#!$1\neval 'exec perl -S \$0 \"\$\@\"'\n\tif \$running_under_some_shell;\n";
$change{"END"} = "";
} elsif (/PERL=(.*)/) { # substitute name for value
$change{"PERL"} = "\@rem = '-*- Perl -*-\n\@echo off\n$1 -S %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9\ngoto endofperl\n';\n";
$change{"END"} = "__END__\n:endofperl\n";
} elsif (/(.*)=(.*)/) { # substitute name for value
$change{$1} = $2;
} else { # open file and substitute
local(@change) = keys %change;
open(FILE, $_) || die "can't open $_";
while ($line = <FILE>) {
grep($line =~ s/\@$_\@/$change{$_}/g, @change);
print $line;
}
close(FILE);
}
}